<?php
class DeliveryCheck extends Check {

    public function addCheck(Model &$model,$condition) {
        if(self::checkStrLength($_POST['name'],2,'min')) {
            $this->flag = false;
            $this->message[] = '物流名称名称不能少于两位!';
        }
        if(self::checkStrLength($_POST['name'],20,'max')) {
            $this->flag = false;
            $this->message[] = '物流名称不能大于二十位!';
        }
        if(self::checkStrLength($_POST['url'],200,'max')) {
            $this->flag = false;
            $this->message[] = '物流官方网址不能大于两百位!';
        }
        if(self::checkStrLength($_POST['info'],255,'max')) {
            $this->flag = false;
            $this->message[] = '物流简介不能大于两百五十五位!';
        }
        if($model->isOne($condition)) {
            $this->flag = false;
            $this->message[] = '物流名称已经被占用!!';
        }
        return $this->flag;
    }

    public function updateCheck() {
        if(self::checkStrLength($_POST['url'],200,'max')) {
            $this->flag = false;
            $this->message[] = '物流官方网址不能大于两百位!';
        }
        if(self::checkStrLength($_POST['info'],255,'max')) {
            $this->flag = false;
            $this->message[] = '物流简介不能大于两百五十五位!';
        }
        return $this->flag;
    }

    public function ajaxCheckName(Model &$model,$condition) {
        echo $model->isOne($condition) ? 1 : 2;
    }

}


?>